<?php

require_once( ORM_DIR.'/extractors/Extractor.php' );

class ObjectListReference implements Extractor {
		
	private $_rightObjectDescriptor;
	
	private $_leftFieldName;
	private $_rightFieldName;
	private $_rightRestrictions;
	
	private $_modificationType;
	
	public function __construct( $leftFieldName, & $rightObjectDescriptor, $rightFieldName, $rightRestrictions = array() ) {
		
		$this->_leftFieldName = $leftFieldName;
		
		$this->_rightFieldName = $rightFieldName;
		$this->_rightObjectDescriptor =& $rightObjectDescriptor;
		$this->_rightRestrictions = $rightRestrictions;
	}

	public function & get( & $storage, array & $fields ) {
		
		// Устанавливаем ограничения на запись, с которой работаем
		$this->_rightRestrictions[ $this->_rightFieldName ] = $fields[ $this->_leftFieldName ];
		
		// Выбираем запись из хранилища
		return $storage->findAllByFields( $this->_rightObjectDescriptor, $this->_rightRestrictions );
	}
	
	public function set( & $storage, array & $fields, $value ) {		
		die( "Cann't modify list objects'" );
	}
}

?>